package PenTest.NetEasy.ACM1;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        Map<String, Integer> map = new HashMap<>();
        int count=6;
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String line = in.nextLine();
            if (line==""||line.length()==0){
                count--;
            }else {
                String[] a= line.split(" ");
                map.put(a[0], map.getOrDefault(a[0], 0) + Integer.parseInt(a[1]));
                int b = in.nextInt();
                in.nextLine();
                for (int i = 0; i < b; i++) {
                    String[] curr=in.nextLine().split(" ");
                    map.put(curr[0], map.getOrDefault(curr[0], 0) + Integer.parseInt(curr[1]));
                }
                if(count==1){
                    break;
                }
            }
        }
        System.out.println("atk "+map.get("atk") );
        System.out.println("atkper "+map.get("atkper") );
        System.out.println("def "+map.get("def") );
        System.out.println("spd "+map.get("spd") );
    }
}